﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.Linq.Expressions;
using System.ComponentModel;

namespace Core.ZTree
{
    public class TreeNode
    {
        public TreeNode()
        {
            //this.Checked = false;
            this.Children = new List<TreeNode>();
            //this.ChkDisabled = false;
            //this.HalfCheck = false;
            //this.Nocheck = false;
            //this.Open = false;
            //this.Drag = true;
            //this.DropInner = true;
        }

        #region 属性
        /// <summary>
        /// 节点的 checkBox / radio 的 勾选状态。
        /// </summary>
        [JsonProperty("checked", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(false)]
        public bool Checked { get; set; }

        [JsonProperty("children", Order = -98)]
        public List<TreeNode> Children { get; set; }

        /// <summary>
        /// 设置节点的 checkbox / radio 是否禁用
        /// </summary>
        [JsonProperty("chkDisabled", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(false)]
        public bool ChkDisabled { get; set; }

        /// <summary>
        /// 强制节点的 checkBox / radio 的 半勾选状态
        /// </summary>
        [JsonProperty("halfCheck", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(false)]
        public bool HalfCheck { get; set; }

        /// <summary>
        /// 节点自定义图标的 URL 路径。
        /// </summary>
        [JsonProperty("icon", NullValueHandling = NullValueHandling.Ignore)]
        public string Icon { get; set; }

        /// <summary>
        /// 父节点自定义折叠时图标的 URL 路径。
        /// </summary>
        [JsonProperty("iconClose", NullValueHandling = NullValueHandling.Ignore)]
        public string IconClose { get; set; }

        /// <summary>
        /// 父节点自定义展开时图标的 URL 路径
        /// </summary>
        [JsonProperty("iconOpen", NullValueHandling = NullValueHandling.Ignore)]
        public string IconOpen { get; set; }

        /// <summary>
        /// 节点自定义图标的 className
        /// </summary>
        [JsonProperty("iconSkin", NullValueHandling = NullValueHandling.Ignore)]
        public string IconSkin { get; set; }

        [JsonProperty("ID", Order = -100)]
        public string ID { get; set; }

        /// <summary>
        /// 节点名称。
        /// </summary>
        [JsonProperty("name", Order = -99)]
        public string Name { get; set; }

        /// <summary>
        /// 设置节点是否隐藏 checkbox / radio [setting.check.enable = true 时有效]
        /// </summary>
        [JsonProperty("nocheck", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(false)]
        public bool Nocheck { get; set; }

        /// <summary>
        /// 记录 treeNode 节点的 展开 / 折叠 状态。
        /// </summary>
        [JsonProperty("open", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(false)]
        public bool Open { get; set; }

        /// <summary>
        /// 设置点击节点后在何处打开 url。[treeNode.url 存在时有效]
        /// </summary>
        [JsonProperty("target", NullValueHandling = NullValueHandling.Ignore)]
        public string Target { get; set; }

        /// <summary>
        /// 节点链接的目标 URL
        /// </summary>
        [JsonProperty("url", NullValueHandling = NullValueHandling.Ignore)]
        public string Url { get; set; }

        /// <summary>
        /// 是否允许拖动
        /// </summary>
        [DefaultValue(true)]
        public bool Drag { get; set; }
        /// <summary>
        /// 是否允许拖动到里面
        /// </summary>
        [DefaultValue(true)]
        public bool DropInner { get; set; }

        /// <summary>
        /// 自定义属性 任意类型
        /// </summary>
        [JsonProperty("Object", DefaultValueHandling = DefaultValueHandling.Ignore,Order=1000)]
        [DefaultValue(null)]
        public object Object { get; set; }


        #endregion

    }

    public enum TreeNodeMoveType
    {
        /// <summary>
        /// 上面
        /// </summary>
        Prev = 1,
        /// <summary>
        /// 内部
        /// </summary>
        Inner = 2,
        /// <summary>
        /// 下面
        /// </summary>
        Next = 3
    }





}